let inDefault = '../../images/profile/dianpu.png'
let appointmentDefault = '../../images/zaqizaba/预约2.png'
let likeDefault = '../../images/zaqizaba/关注灰.png'
let collectionDefault = '../../images/zaqizaba/收藏2.png'
let inActive = '../../images/profile/dianpu.png'
let appointmentActive = '../../images/zaqizaba/subscribe.png'
let likeActive = '../../images/zaqizaba/follow.png'
let collectionActive = '../../images/zaqizaba/collection.png'


$(function(){
  var mySwiper = new Swiper('.swiper-container', {
    speed: 400,
    spaceBetween: 100,
    pagination: {
      el: '.swiper-pagination',
    },
  });
  $('.goods_details_footer_icon').click(function () {
    console.log($(this).index())
    let index = $(this).index();
    let Default,Active;
    switch (index) {
      case 0:
        Default = inDefault;
        Active = inActive;
        break;
      case 1:
        Default = appointmentDefault;
        Active = appointmentActive;
        break;
      case 2:
        Default = likeDefault;
        Active = likeActive;
        break;
      case 3:
        Default = collectionDefault;
        Active = collectionActive;
        break;
    }
    if($(this).find('img').attr('src') == Default){
      $(this).find('img').attr('src',Active)
      $(this).css('color','#FE6161')
      return;
    }
    $(this).find('img').attr('src',Default)
    $(this).css('color','#666666')
  })

  $('.goods_details_tabbar li').click(function () {
    $(this).siblings("li").attr("class","");
    $(this).attr('class','goods_details_tabbar_active')
    let name = $(this).text()
    switch (name) {
      case '主图':
        scrollTo('.goods_details_banner',300)
        break;
      case '点评':
        scrollTo('.goods_comment',300)
        break;
      case '详情':
        scrollTo('.goods_details',300)
        break;
    }
  })



})
function scrollTo(ele, speed){
  console.log(ele)
  if(!speed) speed = 300;
  if(!ele){
    $("html,body").animate({scrollTop:0},speed);
  }else{
    if(ele.length>0) $("html,body").animate({scrollTop:$(ele).offset().top},speed);
  }
  return false;
}

$("#shishangdianping").click(()=>{
  window.location.href='../publish/comment.html'
  
})